#include "Action.h"
#include "Object.h"
#include "SGKAgent.h"
#include <vector>
using std::vector;

bool Action::satisfies(Condition * inQuestion)
{
	if (post.size()){

		for (unsigned int i = 0; i < post.size(); ++i)
		{
			if (inQuestion->ID == post[i].ID && post[i].EvaluateValues(inQuestion->active))
				return true;
		}

		return false;
	}

	return false;
}

bool ActionFireWeapon::satisfied()
{
	if (m_pOwner->GetTehObject() && m_pOwner->GetTehObject()->id == GUN && m_pOwner->GetTarget())
		return true;

	return false;
}

void ActionFireWeapon::activate()
{
	//m_pOwner->SetRadius(m_pOwner->GetRadius() * 0.5f); // shrinkage.  woo.
	animationTime = 1.0f;
}

bool ActionMountTurret::satisfied()
{
	if (God::GetInstance()->GetObjAtLoc(m_pOwner->GetCenter()) == value(GUN))
		return true;

	return false;
}

void ActionMountTurret::activate()
{
	//m_pOwner->SetCenter(m_pOwner->GetCenter() + vec3f(0.0f, 0.2f, 0.0f));
	m_pOwner->GetTehObject()->m_pOwner = m_pOwner;
	animationTime = 1.0f;
}

bool ActionAimGun::satisfied()
{
	if (m_pOwner->GetTehObject() && m_pOwner->GetTehObject()->id == GUN && m_pOwner->GetTarget())
		return true;

	return false;
}

void ActionAimGun::activate()
{
	//m_pOwner->SetRadius(m_pOwner->GetRadius() * 2.0f); // shrinkage.  woo.
	m_pOwner->SetTarget(God::GetInstance()->GetObject(God::GetInstance()->findMeA(PLAYER)));
	animationTime = 1.0f;
}

bool ActionMelee::satisfied()
{
	if (God::GetInstance()->GetObjAtLoc(m_pOwner->GetCenter()) == value(PLAYER))
		return true;

	return false;
}

void ActionMelee::activate()
{
	animationTime = 1.0f;
}

bool ActionGOTO::satisfied()
{
	if (m_pOwner) return true; // you can always go to.

	return false;
}

void ActionGOTO::activate()
{
	animationTime = 1.0f;
}

bool ActionJustChillin::satisfied()
{
	if (m_pOwner) return true;  // and you can always chill.
	return false;
}

void ActionJustChillin::activate()
{
	animationTime = 1.0f;
}

bool ActionGotoPlayer::satisfied()
{
	if (m_pOwner) return true; // assuming agent knows location of player
	return false;
}

void ActionGotoPlayer::activate()
{
	animationTime = 1.0f;
}